package br.com.lambdacore.persistence.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.Map;

import javax.persistence.LockModeType;

import br.com.lambdacore.model.EntityModel;

public interface DAO<T extends EntityModel<PK>, PK extends Serializable> {

	boolean contains(T entity);

	PK create(T entity);

	void delete(T entity);

	void deleteAll(T... entities);

	Collection<T> find(String query, Map<String, ?> parameters);

	Collection<T> findAll();

	Collection<T> findAllFirstResult(Integer firstResult);

	Collection<T> findAllMaxResults(Integer maxResults);

	Collection<T> findAllRange(Integer firstResult, Integer maxResults);

	T findById(PK id);

	Collection<T> findFirstResult(String query, Map<String, ?> parameters,
			Integer firstResult);

	Collection<T> findMaxResults(String query, Map<String, ?> parameters,
			Integer maxResults);

	Collection<T> findRange(String query, Map<String, ?> parameters,
			Integer firstResult, Integer maxResults);

	T findSingleResult(String query, Map<String, ?> parameters);

	T getReference(T entity);

	void insert(T entity);

	void lock(T entity, LockModeType lockModeType);

	void lockRead(T entity);

	void lockWrite(T entity);

	T merge(T entity);

	@Deprecated
	void persist(T entity);

	void refresh(T entity);

	@Deprecated
	void remove(T entity);

	@Deprecated
	void removeAll(T... entities);

	T update(T entity);

}
